package com.pxmeta.user.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pxmeta.user.entity.UserVisit;
import com.pxmeta.user.entity.vo.UserVisitVO;
import com.pxmeta.user.entity.vo.VisitResultVO;
import com.pxmeta.user.mapper.UserVisitMapper;
import com.pxmeta.user.service.IUserVisitService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author hh
 * @since 2022-07-19
 */
@Service
@RequiredArgsConstructor
public class UserVisitServiceImpl extends ServiceImpl<UserVisitMapper, UserVisit> implements IUserVisitService {

    /**
     * 获取 谁看过我 数据
     *
     * @param userId
     * @param page
     * @param size
     * @return
     */
    @Override
    public VisitResultVO getSawMeData(Long userId, Integer page, Integer size) {
        // 获取 谁看过我 数据下
        List<UserVisitVO> userVisitVOS = baseMapper.selectSawMe(userId, page - 1, size);
        Integer todayCount = baseMapper.selectTodaySawCount(userId);
        Integer totalCount = baseMapper.selectSawMeCount(userId);
        VisitResultVO result = new VisitResultVO();
        result.setTodayVisitNum(todayCount);
        result.setVisitList(userVisitVOS);
        result.setTotalVisit(totalCount);
        return result;
    }

    /**
     * 获取 我看过谁 数据
     *
     * @param userId 用户Id
     * @param page
     * @param size
     * @return
     */
    @Override
    public List<UserVisitVO> getSawWhoData(Long userId, Integer page, Integer size) {
        return baseMapper.selectSawWho(userId, page - 1, size);
    }

    @Override
    public Integer selectSawMeCount(Long userId) {
        return baseMapper.selectSawMeCount(userId);
    }
}
